package allTests;

import abbot.util.AWTFixtureHelper;
import operation.*;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import robotCross.TipMatcher;
import socketEnv.DataUtil;
import util.Info;

import java.awt.*;

import static operation.Operation.robot;
import static operation.RibbonOperation.RIBBONOPERATION;

/**
 * Created by caolp on 2017-11-02.
 */
public class TestSpatialStatisticalAnalysis {
	String picturePath = DataUtil.resultPicturePath + "TestSpatialStatisticalAnalysis\\";

	@Before
	public void runBeforeTestMethod() {
		Info.out("@Before - runBeforeTestMethod");
		Operation.helper = new AWTFixtureHelper();
		Operation.robot = Operation.helper.getRobot();
		DialogOperation.closeAllDialog();
		Operation.datasources.clear();
	}

	@After
	public void runAfterTestMethod() throws Exception {
		Info.out("@After - runAfterTestMethod");
		Operation.releaseDatasources();
		DialogOperation.closeAllDialog();
		WorkspaceTreeOperation.closeWorkspace();
	}

	@Test
	public void testCentralElement() throws Exception {
		String udbPath = DataUtil.udbPath("SpatialStatisticalAnalysis/SpatialMeasure.udb");
		String dataSourceType = "打开文件型数据源...";
		new WorkspaceTreeOperation().selectTheDatasouceNodeMenu(dataSourceType);
		new JFileChooserOperation().chooseFile(udbPath);
		robot.delay(2000);
		RIBBONOPERATION.clickButton("可视化建模", "新建");
		ModelTreeOperation modelTreeOperation = new ModelTreeOperation();
		modelTreeOperation.selectTreeNode("空间统计分析", "度量地理分布", "中心要素");
		ModelWindowOperation modelWindowOperation = new ModelWindowOperation();
		modelWindowOperation.dragToCanvasPoint(new Point(0, 50));
		//选中节点，设置参数
		modelWindowOperation.clickProcessGraph("中心要素");
		DockbarOperation dockbarOperation = new DockbarOperation("参数设置");
		//dockbarOperation.setComboBoxSelectedItem(new NameMatcher("ParameterSingleDatasetPanel_" + CommonProperties.getString(CommonProperties.Label_Dataset)), "行政区_P");
	}
}
